﻿using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;

using Ample.Model;

namespace Ample.DAL.User
{
    public static class UserQueries
    {
        public static readonly Func<AmpleDataContext, string, IEnumerable<Model.User>> compiledQuery_GetUserByUsername =
          CompiledQuery.Compile<AmpleDataContext, string, IEnumerable<Model.User>>((adc, username) =>

                from c in adc.Users
                where c.UserName.Equals(username)
                select c
          );

        public static readonly DataLoadOptions UserOptions =
            (new Func<DataLoadOptions>(() =>
            {
                var option = new DataLoadOptions();

                option.LoadWith<Model.User>(u => u.Orders);
                
                return option;
            }))();

    }
}
